home *** CD-ROM | disk | FTP | other *** search
/ Disc to the Future 2 / Disc to the Future Part II Programmer's Reference (Wayzata Technology)(6013)(1992).bin / MAC / MPW_TOOL / TOOLS / TOOLS_WI / FAST_LEX / ALLOCA.A next >
Text File  |  1988-07-04  |  646b  |  20 lines

  1. ;;
  2. ;; Alloca() for Macintosh Programmer's Workshop C.
  3. ;; alloca(n) allocates n bytes of storage in the stack
  4. ;; frame of the caller.
  5. ;;
  6.     CASE ON
  7.     
  8. alloca PROC EXPORT
  9.         move.l  (sp)+,a0        ; pop return address
  10.         move.l  (sp)+,d0        ; pop parameter = size in bytes
  11.         add.l   #3,d0           ; round size up to long word
  12.         and.l   #-4,d0            ; mask out lower two bits of size
  13.         sub.l   d0,sp           ; allocate by moving stack pointer
  14.         move.l  sp,d0           ; return pointer
  15.         add.l   #-4,sp          ; new top of stack
  16.         jmp     (a0)            ; return to caller
  17.         ENDP
  18.         END
  19.         
  20.